package com.jason.mail;

import java.util.Arrays;
import java.util.Properties;

public class MailSenderInfo {

    // 发送邮件的服务器的IP和端口
    private String mailServerHost="smtp.qq.com";
    private String mailServerPort = "465";
    // 邮件发送者的地址
    private String fromAddress="775335103@qq.com";
    // 邮件接收者的地址
    //private String toAddress;
    private String[] toAddresses;
    // 邮件抄送者地址
    private String[] ccAddresses;
    // 登陆邮件发送服务器的用户名和密码
    private String userName="775335103@qq.com";
    private String password="ckgysszgklppbahj";
    // 是否需要身份验证
    private boolean validate = true;
    // 邮件主题
    private String subject;
    // 邮件的文本内容
    private String content;
    // 邮件附件的文件名
    private String[] attachFileNames;
    public MailSenderInfo() {

    }
    public MailSenderInfo(String[] toAddresses,String subject,String content,String[] attachFileNames) {
        this.toAddresses = toAddresses;
        this.subject = subject;
        this.content = content;
        this.attachFileNames = attachFileNames;
    }

    public MailSenderInfo(String[] toAddresses, String[] ccAddresses, String subject,String content,String[] attachFileNames) {
        this.toAddresses = toAddresses;
        this.ccAddresses = ccAddresses;
        this.subject = subject;
        this.content = content;
        this.attachFileNames = attachFileNames;
    }
    /**
     * 获得邮件会话属性
     */
    public Properties getProperties(){
        Properties props = new Properties();
        props.put("mail.smtp.host", this.mailServerHost);
        props.put("mail.smtp.port", this.mailServerPort);
        props.put("mail.smtp.auth", true);
        props.setProperty("mail.transport.protocol", "smtp"); // 使用的协议（JavaMail规范要求）
        props.put("mail.smtp.ssl.enable", "true");
        //设置socketfactory
        props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        //只处理SSL的连接, 对于非SSL的连接不做处理
        props.setProperty("mail.smtp.socketFactory.fallback", "false");
        props.setProperty("mail.smtp.socketFactory.port", mailServerPort);
        return props;
    }
    public String getMailServerHost() {
        return mailServerHost;
    }
    public String getMailServerPort() {
        return mailServerPort;
    }
    public boolean isValidate() {
        return validate;
    }
    public String[] getAttachFileNames() {
        return attachFileNames;
    }
    public void setAttachFileNames(String[] fileNames) {
        this.attachFileNames = fileNames;
    }
    public String getFromAddress() {
        return fromAddress;
    }
    public String[] getToAddresses() {
        return toAddresses;
    }
    public void setToAddresses(String[] toAddresses) {
        this.toAddresses = toAddresses;
    }
    public String getPassword() {
        return password;
    }

    public String[] getCcAddresses() {
        return ccAddresses;
    }

    public void setCcAddresses(String[] ccAddresses) {
        this.ccAddresses = ccAddresses;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getSubject() {
        return subject;
    }
    public void setSubject(String subject) {
        this.subject = subject;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String textContent) {
        this.content = textContent;
    }
    @Override
    public String toString() {
        return "MailSenderInfo [toAddresses=" + Arrays.toString(toAddresses)
                + ", subject=" + subject + ", content=" + content
                + ", attachFileNames=" + Arrays.toString(attachFileNames) + "]";
    }



}
